import advice.CustomAdvice;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.matcher.ElementMatchers;

import java.lang.instrument.Instrumentation;

import static net.bytebuddy.matcher.ElementMatchers.named;

public class BytebuddyAgent {
    public static void premain(String options, Instrumentation ins)
    {
        new AgentBuilder.Default()
                .type(ElementMatchers.any())
                .transform((builder, type, classLoader, module) ->
                        builder.method(named("getversion"))
                                .intercept(Advice.to(CustomAdvice.class))
                ).installOn(ins);
    }

}
